<template>
  <div class="app-container">
    <el-form :inline="true" label-width="80px">
      <el-form-item label="商品名称">
        <el-input v-model="listQuery.goodName"></el-input>
      </el-form-item>

      <el-form-item label="商品来源">
        <el-select v-model="listQuery.userState" placeholder="请选择">
          <el-option label="--" value />
          <el-option label="合作品牌" value="0" />
          <el-option label="盛星品牌" value="1" />
          <el-option label="非药品" value="2" />
          <el-option label="处方药" value="3" />
        </el-select>
      </el-form-item>

      <el-form-item label="批准文号">
        <el-input v-model="listQuery.name"></el-input>
      </el-form-item>

      <el-form-item label="商品状态">
        <el-input v-model="listQuery.name"></el-input>
      </el-form-item>

      <el-form-item label="库存数量">
        <el-input v-model="listQuery.name"></el-input>
      </el-form-item>

      <el-form-item label="会员价格">
        <el-input v-model="listQuery.name"></el-input>
      </el-form-item>

      <el-form-item label="厂商">
        <el-input v-model="listQuery.name"></el-input>
      </el-form-item>

      <el-form-item label="分类">
        <el-input v-model="listQuery.name"></el-input>
      </el-form-item>

      <el-form-item label="是否有图">
        <el-select v-model="listQuery.userState" placeholder="请选择">
          <el-option label="--" value />
          <el-option label="有图" value="0" />
          <el-option label="无图" value="1" />
        </el-select>
      </el-form-item>

      <el-form-item label="拼音排序">
        <el-select v-model="listQuery.userState" placeholder="请选择">
          <el-option label="否" value />
          <el-option label="是" value="0" />
        </el-select>
      </el-form-item>

      <el-form-item label="近期推送">
        <div class="block">
          <el-date-picker
            v-model="value2"
            type="daterange"
            align="right"
            unlink-panels
            range-separator="至"
            start-placeholder="开始日期"
            end-placeholder="结束日期"
            :picker-options="pickerOptions"
          ></el-date-picker>
        </div>
      </el-form-item>

      <el-form-item>
        <el-button type="primary" @click="getList">搜索</el-button>
      </el-form-item>

    </el-form>

    <el-table :data="list" border fit highlight-current-row style="width: 100%">
      <el-table-column fixed prop="date" label="1" width="50"></el-table-column>
      <el-table-column prop="isOrNotHavePicture" label="图片" width="150">
        <template slot-scope="scope">
          <span>{{scope.row.isOrNotHavePicture}}</span>
        </template>
      </el-table-column>

      <el-table-column prop="goodsName" label="名称" width="200">
        <template slot-scope="scope">
          <span>{{scope.row.goodsName}}</span>
        </template>
      </el-table-column>

      <el-table-column prop="goodsTypeStr" label="所属分类" width="120">
        <template slot-scope="scope">
          <span>{{scope.row.goodsTypeStr}}</span>
        </template>
      </el-table-column>

      <el-table-column prop="isSxStr" label="商品来源" width="150">
        <template slot-scope="scope">
          <span>{{scope.row.isSxStr}}</span>
        </template>
      </el-table-column>

      <el-table-column prop="sap" label="规格/批准文号/厂商" width="400">
        <template slot-scope="scope">
          <span>{{scope.row.sap}}</span>
        </template>
      </el-table-column>

      <el-table-column prop="zip" label="已关联合作商" width="150"></el-table-column>

      <el-table-column prop="minimumPrice" label="会员价" width="150">
        <template slot-scope="scope">
          <span>{{scope.row.minimumPrice}}</span>
        </template>
      </el-table-column>

      <el-table-column prop="royalty" label="业务提成价格" width="150">
        <template slot-scope="scope">
          <span>{{scope.row.royalty}}</span>
        </template>
      </el-table-column>

      <el-table-column fixed="right" label="活动操作" width="100">
        <template>
          <el-button type="text" size="small">抵用券禁用</el-button>
        </template>
      </el-table-column>

      <el-table-column fixed="right" label="操作" width="70">
        <template>
          <el-button type="text" size="small">编辑</el-button>
        </template>
      </el-table-column>

      <el-table-column fixed="right" label="更多操作" width="100">
        <template slot-scope="scope">
          <el-dropdown trigger="click">
            <span class="el-dropdown-link">
              操作
              <i class="el-icon-arrow-down el-icon--right"></i>
            </span>
            <el-dropdown-menu slot="dropdown">
              <el-dropdown-item @click.native="openData(scope.row)">首营资料</el-dropdown-item>
              <el-dropdown-item @click.native="pcopenUpload(scope.row)">PC图片上传</el-dropdown-item>
              <el-dropdown-item @click.native="appopenUpload(scope.row)">APP图片上传</el-dropdown-item>
              <el-dropdown-item @click.native="goodsopenUpload(scope.row)">商品详情图片上传</el-dropdown-item>
              <el-dropdown-item @click.native="pcSortopen(scope.row)">PC图片排序</el-dropdown-item>
              <el-dropdown-item @click.native="appSortopen(scope.row)">APP图片排序</el-dropdown-item>
              <el-dropdown-item @click.native="goodsDetailsopen(scope.row)">商品详情图片排序</el-dropdown-item>
              <el-dropdown-item @click.native="drugDeployopen(scope.row)">联合用药配置</el-dropdown-item>
              <el-dropdown-item @click.native="goodsRelationopen(scope.row)">关联产品</el-dropdown-item>
              <el-dropdown-item @click.native="modifyPriceopen(scope.row)">提成价格</el-dropdown-item>
            </el-dropdown-menu>
          </el-dropdown>
        </template>
      </el-table-column>
    </el-table>

    <pagination
      v-show="total>0"
      :total="total"
      :page.sync="listQuery.currentPage"
      :limit.sync="listQuery.showCount"
      @pagination="getList"
    />

    <libraryData ref="libraryData" />
    <pclibraryUpload ref="pclibraryUpload" />
    <applibraryUpload ref="applibraryUpload" />
    <goodsUpload ref="goodsUpload" />
    <pcSort ref="pcSort" />
    <appSort ref="appSort" />
    <goodsDetails ref="goodsDetails" />
    <goodsRelation ref="goodsRelation" />
    <drugDeploy ref="drugDeploy" />
    <modifyPrice ref="modifyPrice" />
  </div>
</template>

<script>
import apigoodsManage from "@/api/goodsManage/goodslibrary";
import Pagination from "@/components/Pagination";
import libraryData from "./dialogLibraryData";
import pclibraryUpload from "./dialogPcLibraryUpload";
import applibraryUpload from "./dialogAppLibraryUpload";
import goodsUpload from "./dialogPcLibraryUpload";
import pcSort from "./dialogAppSort";
import appSort from "./dialogAppSort";
import goodsDetails from "./dialogGoodsDetails";
import drugDeploy from "./dialogDrugDeploy";
import goodsRelation from "./dialogGoodsRelation";
import modifyPrice from "./dialogModifyPrice";
export default {
  name: "goodslibrary",
  components: {
    Pagination,
    libraryData,
    pclibraryUpload,
    applibraryUpload,
    goodsUpload,
    pcSort,
    appSort,
    goodsDetails,
    goodsRelation,
    drugDeploy,
    modifyPrice
  },
  data() {
    return {
      value2: "",
      total: 0,
      list: [],
      pickerOptions: {
        shortcuts: [
          {
            text: "最近一周",
            onClick(picker) {
              const end = new Date();
              const start = new Date();
              start.setTime(start.getTime() - 3600 * 1000 * 24 * 7);
              picker.$emit("pick", [start, end]);
            }
          },
          {
            text: "最近一个月",
            onClick(picker) {
              const end = new Date();
              const start = new Date();
              start.setTime(start.getTime() - 3600 * 1000 * 24 * 30);
              picker.$emit("pick", [start, end]);
            }
          },
          {
            text: "最近三个月",
            onClick(picker) {
              const end = new Date();
              const start = new Date();
              start.setTime(start.getTime() - 3600 * 1000 * 24 * 90);
              picker.$emit("pick", [start, end]);
            }
          }
        ]
      },
      listQuery: {
        currentPage: 1,
        showCount: 10,
        goodName: "",
        isSx: "",
        approvalNumber: "",
        isPublish: "0,1,2",
        sstockCount: "",
        bstockCount: "",
        smemberPrice: "",
        bmemberPrice: "",
        productionFactoryName: "",
        typeName: "",
        isOrNotHavePicture: "",
        spellArray: 0,
        startTime: "",
        endTime: ""
      }
    };
  },
  created() {
    //初始化列表
    this.getList();
  },
  methods: {
    getList() {
      const data = apigoodsManage.getListMap2();
      this.list = data.list;
      this.total = data.page.totalResult;

    },
    //首营资料
    openData(row) {
      this.$refs.libraryData.open(row);
    },
    //PC图片上传
    pcopenUpload(row) {
      this.$refs.pclibraryUpload.open(row);
    },
    //APP图片上传
    appopenUpload(row) {
      this.$refs.applibraryUpload.open(row);
    },
    //商品详情图片上传
    goodsopenUpload(row) {
      this.$refs.goodsUpload.open(row);
    },
    //PC图片排序
    pcSortopen(row) {
      this.$refs.pcSort.open(row);
    },
    //APP图片排序
    appSortopen(row) {
      this.$refs.appSort.open(row);
    },
    //商品详情图片排序
    goodsDetailsopen(row) {
      this.$refs.goodsDetails.open(row);
    },
    //联合用药配置
    drugDeployopen(row) {
      this.$refs.drugDeploy.open(row);
    },
    //关联商品
    goodsRelationopen(row) {
      this.$refs.goodsRelation.open(row);
    },
    //提成价格
    modifyPriceopen(row) {
      this.$refs.modifyPrice.open(row);
    }
  }
};
</script>

<style  scoped>
</style>